<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
  <base href="<%=basePath %>">
  <meta charset="utf-8">
  <title>修改密码</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <!-- 自动适应设备宽度 -->
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="js/layui/css/layui.css" media="all">
 
</head>
<body>
    <br/>
    <form class="layui-form" action="">
		  <div class="layui-form-item">
		    <label class="layui-form-label">原密码：</label>
		    <div class="layui-input-inline">
		      <input type="password" name="oldPwd"  
		        autocomplete="off" placeholder="请输入原密码" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">新密码：</label>
		    <div class="layui-input-inline">
			      <input type="password" name="newPwd"  id="newPwd" lay-verify="pass" autocomplete="off"
			        autocomplete="off" placeholder="请输入新密码" class="layui-input">
		    </div>
		    <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
		  </div>
	     <div class="layui-form-item">
		    <label class="layui-form-label">确认密码：</label>
		    <div class="layui-input-inline">
			     <input type="password" name="confirmPwd" lay-verify="equalNew" autocomplete="off"
			       			autocomplete="off" placeholder="请再次输入新密码" class="layui-input">
		    </div>
		    <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
		  </div>
		 <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button type="submit" class="layui-btn" lay-submit="" lay-filter="updPassword">立即提交</button>
		      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		    </div>
	  	</div>
    </form>
    <script type="text/javascript" src="js/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript">
     layui.use(['form','jquery'], function(){
		  var form = layui.form
		  ,layer = layui.layer
		  ,$=layui.jquery;
				 
		  //自定义验证规则
		  form.verify({
		    title: function(value){
		      if(value.length < 5){
		        return '标题至少得5个字符啊';
		      }
		    }
		    ,pass: [
		      /^[\S]{6,12}$/
		      ,'密码必须6到12位，且不能出现空格'
		    ]
		    ,equalNew:function(value){
		        var newPwd = $('#newPwd').val();
				if(value != newPwd){
					return '两次输入的密码不一致!';
		        }
		     }		     
		  });		  
		 
		  //监听提交
		  form.on('submit(updPassword)', function(data){
		    //异步提交
		    $.post("login/updatePwd.do", data.field,function(json){
		    	if(json.statusCode=="300"){
		    		layer.msg(json.message);		
		    	}
		    	if(json.statusCode=="200"){
		    		layer.msg(json.message);
		    		//添加修改完成的业务逻辑		
		    		top.window.location.href=json.redirectUrl;
		    	} 
		     }, "json");
		  
		  
		   
		    /* console.log("-----------"+JSON.stringify(data));
		    layer.alert(JSON.stringify(data.field), {
		      title: '最终的提交信息'
		    });		 */    
		    
		    return false;
		  });			  
		});
    </script>
  </body>
</html>